package com.ecjtu.stadiumre_servations.controller;

import com.ecjtu.stadiumre_servations.entity.domain.Student;
import com.ecjtu.stadiumre_servations.entity.domain.User;
import com.ecjtu.stadiumre_servations.entity.dto.LoginDTO;
import com.ecjtu.stadiumre_servations.entity.dto.UserDTO;
import com.ecjtu.stadiumre_servations.response.Result;
import com.ecjtu.stadiumre_servations.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/user")
public class UserController {
    @Autowired
    private UserService userService;
    @PostMapping("/login")
    public Result UserLogin(@RequestBody LoginDTO loginDTO){

        return userService.login(loginDTO);
    }
    @PostMapping("/register")
    public Result UserRegister(@RequestBody UserDTO userDTO){
        return userService.register(userDTO);
    }
    @PostMapping("/updatePassword")
    public Result updatePassword(@RequestParam String oldPassword, @RequestParam String newPassword) {
        return userService.updatePassword(oldPassword, newPassword);
    }
    @PostMapping("/updatePhone")
    public Result updatePhone(@RequestParam String oldPhone, @RequestParam String newPhone) {
        return userService.updatePhone(oldPhone, newPhone);
    }

}
